package com.yunhe.abnormal.client.fallback;

import com.yunhe.abnormal.client.AuthorityClient;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.authority.FirmDTO;
import com.yunhe.common.model.authority.Role;
import com.yunhe.common.model.authority.StationDTO;
import com.yunhe.common.model.authority.UserDTO;
import com.yunhe.common.util.FallbackUtil;
import feign.hystrix.FallbackFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author liuronglei
 */
@Component
public class AuthorityFallbackFactory implements FallbackFactory<AuthorityClient> {
    @Override
    public AuthorityClient create(Throwable arg0) {
        return new AuthorityClient() {

            @Override
            public ResponseEntity<ResultObject<FirmDTO>> getFirmById(Long id) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<StationDTO>> getStationByCode(Long code) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<UserDTO>> getUserById(Long id) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<List<StationDTO>>> getStationByFirmId(Long firmId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<StationDTO>> getStationById(Long stationId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<StationDTO>> getStationByDeviceId(Long deviceId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<List<Role>>> getRolesByUserId(Long id) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<List<UserDTO>>> getRelatedUserByStationId(Long stationId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<String>> getTimeZoneIdByStationId(Long stationId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<List<StationDTO>>> searchStation(Long stationTypeId) {
                return FallbackUtil.getDefaultFallBack();
            }
        };
    }
}
